package com.yunhe.transfer.client.fallback;

import com.yunhe.transfer.client.MeasRealtimeClient;
import com.yunhe.common.model.DomainList;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.Measurement;
import com.yunhe.common.model.data.MeasurementReqDTO;
import com.yunhe.common.model.device.Analog;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MeasRealtimeFallbackFactory implements FallbackFactory<MeasRealtimeClient> {
    @Override
    public MeasRealtimeClient create(Throwable cause) {
        return new MeasRealtimeClient() {

            @Override
            public void save(Map<Long, Double> map) {

            }

            @Override
            public void saveObj(DomainList<Measurement> domainList) {

            }

            @Override
            public ResponseEntity<ResultObject<Object>> saveOneObj(Measurement measurement) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Map<Long, Measurement>>> getValue(Long pointNumber) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Map<Long, Double>>> getMeasureRealtime(MeasurementReqDTO map) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> clearBackup(MeasurementReqDTO map) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> movetoBackup(MeasurementReqDTO map) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Map<Long, Double>>> getBackup(MeasurementReqDTO map) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> updateMeasureRealtime(Long pointNumber, Long rtime, String dtime, Double val) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
